package com.zjg.dao;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.zjg.bean.Hobby;
import com.zjg.dao.iface.HobbyDao;
import com.zjg.db.utills.JdbcTemplate;

public class HobbyDaoImp implements HobbyDao {

	@Override
	public List<Hobby> getHobbies() {
		String sql = "select * from HOBBY";
		List<Hobby> list = JdbcTemplate.query(sql, (rs) -> {
			List<Hobby> list0 = new ArrayList<Hobby>();
			try {
				while (rs.next()) {
					Hobby hobby = new Hobby(rs.getInt(1), rs.getString(2), rs.getString(3));
					list0.add(hobby);
				}
			} catch (SQLException e) {

				e.printStackTrace();
			}

			return list0;
		}, null);

		return list;
	}

}
